/**
 * 
 */
package org.freemarker.core.service.impl;

import java.util.List;

import org.freemarker.core.dao.EntityJpaDao;
import org.freemarker.core.model.BaseEntity;
import org.freemarker.core.model.Car;
import org.freemarker.core.service.BaseService;
import org.freemarker.core.model.Contact;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @param <T>
 */
@Transactional
public class BaseServiceImpl<T extends BaseEntity> implements BaseService<T> {

	protected EntityJpaDao<T> entityJpaDao;

	@Override
	public T findOne(Long id) {
		return entityJpaDao.findOne(id);
	}

	@Override
	@Transactional(readOnly=true)
	public List<T> findAll() {
		return entityJpaDao.findAll();
	}
	
	@Override
	@Transactional(readOnly=true)
	public List<T> findLast(){
		return entityJpaDao.findLast();
	}
//	@Override
//	@Transactional(readOnly=true)
//	public List<Car> findNotUsed(){
//		return CarDao.findNotUsed();
//	}
	@Override
	@Transactional
	public Long save(T entity) {
		return entityJpaDao.save(entity);
	}

	@Override
	@Transactional
	public void update(T entity) {
		entityJpaDao.update(entity);
	}

	@Override
	@Transactional
	public void delete(T entity) {
		entityJpaDao.delete(entity);
	}

	@Override
	@Transactional
	public void deleteById(Long entityId) {
		entityJpaDao.deleteById(entityId);
	}

	@Override
	public void updateById(Long entityId) {
		entityJpaDao.updateById(entityId);
		
	}
	
	@Override
	public void deleteByName(Long entityId){
		entityJpaDao.deleteByName(entityId);
	}

	@Override
	public void saveContact(Contact c) {
		entityJpaDao.saveContact(c);
	}
	
	@Override
	public void updateBySecurityNumber(String securityNumber) {
		entityJpaDao.updateBySecurityNumber(securityNumber);
		
	}

}
